/***
 * @Description:
 * @Author: LI Yihong
 * @Email: liyh@jihua.ac.cn
 * @Date: 2024-09-29 09:22:57
 * @LastEditTime: 2024-09-29 09:25:23
 * @LastEditors: LI Yihong
 * @FilePath: \RT_Stm32F7\applications\test\armKeyTest.h
 */
#pragma once
#include "Thread.h"
#include "Semaphore.h"
#include "Mail.h"
#include "Queue.h"
#include <drivers/pin.h>
#include <string>
#include <memory>
#include <board.h>
#include "stm32f7xx_hal.h"

using namespace rtthread;
using std::shared_ptr;

class ArmKey : public Thread
{
public:
    using Thread::Thread;

    void run(void *parameter) override;

    void setButtonSem(shared_ptr<Semaphore> sem)
    {
        this->buttonSem = sem;
    }
    void setLedSem(shared_ptr<Semaphore> sem)
    {
        this->ledSem = sem;
    }
    void setButtonMail(shared_ptr<Mail<std::string, 10>> mail)
    {
        this->buttonMail = mail;
    }
    void setButtonQueue(shared_ptr<Queue<int, 10>> queue)
    {
        this->buttonQueue = queue;
    }

    static void buttonCallback(void *ptr);

private:
    shared_ptr<Semaphore> buttonSem;
    shared_ptr<Semaphore> ledSem;
    shared_ptr<Mail<std::string, 10>> buttonMail;
    shared_ptr<Queue<int, 10>> buttonQueue;

    void keyInit();
};
